from django.urls import path, re_path
from . import views

urlpatterns = [
    # 路由映射指的就是,把一个请求（Ｈｔｔｐ请求）和处理的视图函数一一对应起来（映射）
    # 路由映射公式：　请求方式　＋　请求路径　＝　视图方法    django
    re_path(r"^usernames/(?P<username>[a-zA-Z0-9_-]{5,20})/count/$", views.UsernameCountView.as_view()),
    # 自定义路由方式 <自定义路由别名:路由提取的关键字参数>
    # path("/usernames/<username:username>/count", views.UsernameCountView.as_view())
    # path("/mobiles/<mobile:mobile>/count/", views.MobileCountView.as_view())
    re_path(r"^mobiles/(?P<mobiles>1[3-9]\d{9})/count/$", views.MobileCountView.as_view()),
    path("register/", views.RegisterView.as_view()),
    path("login/", views.LoginView.as_view()),
    path("logout/", views.LogoutView.as_view()),
    path("info/", views.UserInfoView.as_view()),
    re_path(r"^emails/$", views.EmailView.as_view()),
    re_path(r"^emails/verification/$", views.VerifyEmailView.as_view()),
    re_path(r"^addresses/create/$", views.CreateAddressView.as_view()),
    re_path(r"^addresses/$", views.AddressView.as_view()),
    # 一定要注意末尾　/
    re_path(r"^addresses/(?P<address_id>\d+)/$", views.UpdateDestroyAddressView.as_view()),
    re_path(r"^addresses/(?P<address_id>\d+)/default/$", views.DefaultAddressView.as_view()),
    re_path(r"^addresses/(?P<address_id>\d+)/title/$", views.UpdateTitleAddressView.as_view()),
    re_path(r"^password/$", views.ChangePasswordView.as_view()),


]
